home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / utilities / blankers / blitzblank_260 / developer / modulesources / bb.mosaic.c < prev    next >
C/C++ Source or Header  |  1995-05-18  |  3KB  |  123 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. #include <dos/dos.h>
  6. #include <exec/memory.h>
  7. #include <intuition/intuitionbase.h>
  8. #include <intuition/screens.h>
  9. #include <intuition/intuition.h>
  10. #include <proto/exec.h>
  11. #include <proto/intuition.h>
  12. #include <proto/graphics.h>
  13. #include <pragmas/blitzblank_pragmas.h>
  14.  
  15. #include <BlitzBlank.h>
  16.  
  17. struct Library *BlitzBlankBase;
  18.  
  19. static const char version[]="$VER: BB.Mosaic 2.60 (21.04.95)";
  20.  
  21. char *text[]={"\33c\33uMosaic\33n\n\nModule for BlitzBlank\n\nCopyright 1995\nby\nThomas Börkel",
  22.               "Sp_eed:",
  23.               "Si_ze:",
  24.               "_Refresh Cycle:",
  25.               "_Brightness:",
  26.               "_Delay:" };
  27.  
  28. struct BB_Object object[]={ {&object[1],BB_VGroup,0,0,0,NULL,NULL},
  29.                             {&object[2],BB_Slider,1,100,100,NULL,NULL},
  30.                             {&object[3],BB_Slider,3,100,8,NULL,NULL},
  31.                             {&object[4],BB_Slider,10,500,50,NULL,NULL},
  32.                             {&object[5],BB_Slider,0,100,70,NULL,NULL},
  33.                             {&object[6],BB_Slider,0,20,1,NULL,NULL},
  34.                             {NULL,BB_VGroup_End,0,0,0,NULL,NULL} };
  35.  
  36. struct BB_Message message;
  37. struct BB_Screeninfo *screeninfo;
  38.  
  39.  
  40. void blank (void)
  41. {
  42.   int i,x,y,c,sizex,sizey,sizex2,sizey2;
  43.   long a=0;
  44.   struct RastPort *rp;
  45.  
  46.   rp=&screeninfo->bbscreen->RastPort;
  47.  
  48.   sizex=object[2].set;
  49.   sizey=sizex*screeninfo->xpixelsize/screeninfo->ypixelsize;;
  50.   sizex2=sizex/2;
  51.   sizey2=sizey/2;
  52.  
  53.   ScreenToFront (screeninfo->bbscreen);
  54.  
  55.   if (!CheckSignal (SIGBREAKF_CTRL_C))
  56.   {
  57.     BBL_ModuleRunning ();
  58.     if (BBL_FadeDown (screeninfo->bbscreen,object[4].set,object[5].set))
  59.     {
  60.       do
  61.       {
  62.         WaitTOF ();
  63.         for (i=1;i<=object[1].set;i++)
  64.         {
  65.           x=drand48 ()*(screeninfo->width-sizex)+sizex2;
  66.           y=drand48 ()*(screeninfo->height-sizey)+sizey2;
  67.           c=ReadPixel (rp,x,y);
  68.           SetAPen (rp,c);
  69.           RectFill (rp,x-sizex2,y-sizey2,x+sizex2,y+sizey2);
  70.           a++;
  71.  
  72.           if (a>10000*object[3].set)
  73.           {
  74.             a=0;
  75.             BBL_CopyOriginalScreen (screeninfo->bbscreen);
  76.           }
  77.         }
  78.       } while (!CheckSignal (SIGBREAKF_CTRL_C));
  79.     }
  80.   }
  81.   return;
  82. }
  83.  
  84.  
  85. void main (int argc,char **argv)
  86. {
  87.   int i;
  88.  
  89.   if (!(BlitzBlankBase=OpenLibrary ("blitzblank.library",BLITZBLANKLIB_VER)))
  90.     exit (0);
  91.  
  92.   message.flags=BBF_CloneScreen;
  93.   message.first=&object[0];
  94.  
  95.  
  96.   if (strcmp (argv[1],"BLANK")==0)
  97.   {
  98.     StrToLong (argv[3],(long *) &screeninfo);
  99.     BBL_SendMessage (&message,argv[2]);
  100.     if (screeninfo->bbscreen)
  101.       blank ();
  102.     BBL_BlankDone ();
  103.   }
  104.   else
  105.   {
  106.     message.infotext=BBL_GetString (240,text[0]);
  107.     for (i=1;i<=5;i++)
  108.       object[i].label=BBL_GetString (240+i,text[i]);
  109.     if (strcmp (argv[1],"CONFIG")==0)
  110.     {
  111.       BBL_SendMessage (&message,argv[2]);
  112.     }
  113.     else
  114.     {
  115.       message.first=NULL;
  116.       BBL_SendMessage (&message,argv[2]);
  117.     }
  118.   }
  119.   CloseLibrary (BlitzBlankBase);
  120.   exit (0);
  121. }
  122.  
  123.